@extends('admin.index', ['header' => '事业部看板'])

@section('content')
    <div id="app" class=" ">
        <section class="content-header">
            <h1>
                推送消息
            </h1>

        </section>

        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <div class="box box-info">
                        <div class="form-horizontal">
                            <div class="box-body">
                                <div class="fields-group">
                                    <div class="form-group ">
                                        <label class="col-sm-2 control-label">接收者</label>
                                        <div class="col-sm-8">
                                            <div class="box-body">
                                                {{ $user->name }}
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label class="col-sm-2 control-label">邮箱</label>
                                        <div class="col-sm-8">
                                            <div class="box-body">
                                                {{ $user->email }}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label class="col-sm-2 control-label">内容</label>
                                        <div class="col-sm-8">
                                            <textarea name="text" class="form-control push-content"
                                                      data-reveive-user="{{ $user->id }}"
                                                      rows="8" placeholder="请输入事件内容"></textarea>
                                        </div>
                                    </div>
                                    <div class="box-footer">
                                        <label class="col-sm-2 control-label"></label>
                                        <div class="btn-group">
                                            <button type="button" class="btn btn-info push-confirm">提交</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <script>
        $(function () {
            $(".push-confirm").click(function(){
                var push = $(".push-content");
                var message = push.val();
                var reveive_user = push.attr("data-reveive-user");
                emit("event_talk", {
                    "send_user": '25',
                    "receive_user": reveive_user,
                    "text_message": message
                });
                {{ admin_toastr('推送成功', 'success') }};
                location.href = "/admin/school/user";
            })
        })

    </script>
@endsection